home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / sospRecord.h < prev    next >
C/C++ Source or Header  |  1991-05-06  |  15KB  |  496 lines

  1. #ifdef SOSP91
  2. /*
  3.  * sospRecord.h --
  4.  *
  5.  *    Declarations of macros to insert log records for the sosp paper
  6.  *    measurements.
  7.  *
  8.  * Copyright 1990 Regents of the University of California
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  *
  17.  * $Header: /sprite/src/kernel/utils/RCS/sospRecord.h,v 1.25 91/05/06 14:54:27 kupfer Exp $ SPRITE (Berkeley)
  18.  */
  19.  
  20. #ifndef _SOSP_RECORD
  21. #define _SOSP_RECORD
  22.  
  23.  
  24. #ifdef KERNEL
  25. #include <traceLog.h>
  26. #include <fs.h>
  27.  
  28. extern TraceLog_Header *SOSP91TracePtr;
  29. #endif
  30.  
  31. /*
  32.  * Letters to keep track of trace versions.
  33.  * Version 2: January 9
  34.  */
  35. #define VERSION1    'A'
  36. #define VERSION2    'B'
  37. #define VERSION3    'C'
  38.  
  39. #define VERSIONLETTER    VERSION2
  40.  
  41. /*
  42.  * Definitions for the types of log records.  These are the events being
  43.  * traced.
  44.  */
  45. #define SOSP_INVALID        0
  46. #define    SOSP_OPEN        1
  47. #define    SOSP_DELETE        2
  48. #define    SOSP_CREATE        3
  49. #define    SOSP_MKLINK        4
  50. #define    SOSP_SET_ATTR        5
  51. #define    SOSP_GET_ATTR        6
  52. #define    SOSP_LSEEK        7
  53. #define    SOSP_CLOSE        8
  54. #define    SOSP_MIGRATE        9
  55. #define    SOSP_TRUNCATE        10
  56. #define    SOSP_CONSIST_CHANGE    11
  57. #define    SOSP_READ        12
  58. #define    SOSP_LOOKUP        13
  59. #define    SOSP_CONSIST_ACTION    14
  60. #define SOSP_PREFIX        15
  61. #define SOSP_LOOKUP_OP        16
  62. #define SOSP_DELETE_DESC    17
  63.  
  64. #define SOSP_NUM_EVENTS        18
  65.  
  66. #ifdef KERNEL
  67. /*
  68.  * The following are macros to call for each type of event to trace.  All
  69.  * parameters are int's, unless otherwise marked (such as Fs_FileID's).
  70.  */
  71.  
  72. /*
  73.  * Trace an open command.  The parameters are
  74.  *
  75.  * currentHostID:    Current client requesting open command
  76.  * homeHostID:        HostID of process requesting open before migration
  77.  * fileID        The file ID for the file being opened
  78.  * streamID        Fs_FileID in the header of stream returned for this open
  79.  * effID:        Effective user id doing the open
  80.  * realID:        Real user id doing the open
  81.  * mode            Mode flags of the open command
  82.  * numNowReading    Number of clients with file open for reading after open
  83.  * numNowWriting    Number of clients with file open for writing
  84.  * create        The create time for the file
  85.  * fileSize        Size in bytes of the file
  86.  * modify        The modify time for the file.
  87.  * type            Whether it's an FS_FILE, FS_DIRECTORY, etc.
  88.  * consist        Whether a consistency update was performed due to open
  89.  */
  90. #define    SOSP_ADD_OPEN_TRACE(currentHostID, homeHostID, fileID, streamID, effID, realID, mode, numNowReading, numNowWriting, create, fileSize, modify, type, consist) \
  91. {\
  92.     unsigned int    sospBuffer[21];\
  93. \
  94.     sospBuffer[0] = SOSP_OPEN;\
  95.     sospBuffer[1] = currentHostID;\
  96.     sospBuffer[2] = homeHostID;\
  97.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  98.     *((Fs_FileID *) &(sospBuffer[7])) = streamID;\
  99.     sospBuffer[11] = effID;\
  100.     sospBuffer[12] = realID;\
  101.     sospBuffer[13] = mode;\
  102.     sospBuffer[14] = numNowReading;\
  103.     sospBuffer[15] = numNowWriting;\
  104.     sospBuffer[16] = create;\
  105.     sospBuffer[17] = fileSize;\
  106.     sospBuffer[18] = modify;\
  107.     sospBuffer[19] = type;\
  108.     sospBuffer[20] = consist;\
  109.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  110.         (20 * sizeof (int)), SOSP_OPEN);\
  111. }
  112.  
  113. /*
  114.  * Trace a delete operation.  The fields are
  115.  * 
  116.  * currentHostID:    Current client requesting delete
  117.  * homeHostID:        HostID of process requesting delete before migration
  118.  * fileID        The file ID for the file being deleted
  119.  * modify        The modify time for the file
  120.  * create        The create time for the file.
  121.  * fileSize        Size in bytes of the file
  122.  */ 
  123. #define    SOSP_ADD_DELETE_TRACE(currentHostID, homeHostID, fileID, modify, create, fileSize) \
  124. {\
  125.     unsigned int    sospBuffer[10];\
  126. \
  127.     sospBuffer[0] = SOSP_DELETE;\
  128.     sospBuffer[1] = currentHostID;\
  129.     sospBuffer[2] = homeHostID;\
  130.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  131.     sospBuffer[7] = modify;\
  132.     sospBuffer[8] = create;\
  133.     sospBuffer[9] = fileSize;\
  134.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  135.         (9 * sizeof (int)), SOSP_DELETE);\
  136. }
  137.     
  138. /*
  139.  * Trace a create operation.  The fields are
  140.  * 
  141.  * currentHostID:    Current client requesting create command
  142.  * homeHostID:        HostID of process requesting create before migration
  143.  * fileID        The file ID for the file being created
  144.  */ 
  145. #define    SOSP_ADD_CREATE_TRACE(currentHostID, homeHostID, fileID)\
  146. {\
  147.     unsigned int    sospBuffer[7];\
  148. \
  149.     sospBuffer[0] = SOSP_DELETE;\
  150.     sospBuffer[1] = currentHostID;\
  151.     sospBuffer[2] = homeHostID;\
  152.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  153.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  154.         (6 * sizeof (int)), SOSP_DELETE);\
  155. }
  156.  
  157. /*
  158.  * Trace a mklink operation.  The fields are
  159.  * 
  160.  * currentHostID:    Current client requesting mklink command
  161.  * homeHostID:        HostID of process requesting mklink before migration
  162.  * fileID        The file ID for the file being mklink'ed
  163.  */ 
  164. #define    SOSP_ADD_MKLINK_TRACE(currentHostID, homeHostID, fileID)\
  165. {\
  166.     unsigned int    sospBuffer[28];\
  167. \
  168.     sospBuffer[0] = SOSP_MKLINK;\
  169.     sospBuffer[1] = currentHostID;\
  170.     sospBuffer[2] = homeHostID;\
  171.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  172.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  173.         (6 * sizeof (int)), SOSP_MKLINK);\
  174. }
  175.  
  176.  
  177. /*
  178.  * Trace a set attr operation.  The fields are
  179.  * 
  180.  * currentHostID:    Current client requesting set attr command
  181.  * homeHostID:        HostID of process requesting set attr before migration
  182.  * fileID        The file ID for the file being set attr'ed
  183.  * userID        The user ID of the person making the request
  184.  */ 
  185. #define    SOSP_ADD_SET_ATTR_TRACE(currentHostID, homeHostID, fileID, userID)\
  186. {\
  187.     unsigned int    sospBuffer[32];\
  188. \
  189.     sospBuffer[0] = SOSP_SET_ATTR;\
  190.     sospBuffer[1] = currentHostID;\
  191.     sospBuffer[2] = homeHostID;\
  192.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  193.     sospBuffer[7] = userID;\
  194.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  195.         (7 * sizeof (int)), SOSP_SET_ATTR);\
  196. }
  197.  
  198.  
  199. /*
  200.  * Trace a get attr operation.  The fields are
  201.  * 
  202.  * currentHostID:    Current client requesting get attr command
  203.  * homeHostID:        HostID of process requesting get attr before migration
  204.  * fileID        The file ID for the file being get attr'ed
  205.  * userID        The user ID of the person making the request
  206.  */ 
  207. #define    SOSP_ADD_GET_ATTR_TRACE(currentHostID, homeHostID, fileID, userID)\
  208. {\
  209.     unsigned int    sospBuffer[32];\
  210. \
  211.     sospBuffer[0] = SOSP_GET_ATTR;\
  212.     sospBuffer[1] = currentHostID;\
  213.     sospBuffer[2] = homeHostID;\
  214.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  215.     sospBuffer[7] = userID;\
  216.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  217.         (7 * sizeof (int)), SOSP_GET_ATTR);\
  218. }
  219.  
  220. /*
  221.  * Trace an lseek operation.  The fields are
  222.  * 
  223.  * streamID        Fs_FileID in the header of stream for this operation
  224.  * oldOffset        Offset of stream before lseek
  225.  * newOffset        Offset of stream after lseek
  226.  * flags        The RW flags from the streamPtr->hdr.flags.
  227.  */ 
  228. #define    SOSP_ADD_LSEEK_TRACE(streamID, oldOffset, newOffset, flags)\
  229. {\
  230.     unsigned int    sospBuffer[8];\
  231. \
  232.     sospBuffer[0] = SOSP_LSEEK;\
  233.     *((Fs_FileID *) &(sospBuffer[1])) = streamID;\
  234.     sospBuffer[5] = oldOffset;\
  235.     sospBuffer[6] = newOffset;\
  236.     sospBuffer[7] = flags;\
  237.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  238.         (7 * sizeof (int)),SOSP_LSEEK);\
  239. }
  240.  
  241. /*
  242.  * Trace a close operation.  The fields are
  243.  * 
  244.  * streamID        Fs_FileID in the header of stream for this operation
  245.  * currentOffset    Offset of stream
  246.  * fileSize        Size of file being closed
  247.  * flags        Stream flags.
  248.  * rwflags        The RW flags from the streamPtr->hdr.flags.
  249.  * refCount        Number of references to stream.  Only valid if
  250.  *            FS_RMT_SHARED is set in the flags.
  251.  * consist        Whether a consistency update was done due to close
  252.  */ 
  253. #define    SOSP_ADD_CLOSE_TRACE(streamID, currentOffset, fileSize, flags, rwflags, refCount, consist) \
  254. {\
  255.     unsigned int    sospBuffer[11];\
  256. \
  257.     sospBuffer[0] = SOSP_CLOSE;\
  258.     *((Fs_FileID *) &(sospBuffer[1])) = streamID;\
  259.     sospBuffer[5] = currentOffset;\
  260.     sospBuffer[6] = fileSize;\
  261.     sospBuffer[7] = flags;\
  262.     sospBuffer[8] = rwflags;\
  263.     sospBuffer[9] = refCount;\
  264.     sospBuffer[10] = consist;\
  265.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  266.         (10 * sizeof (int)),SOSP_CLOSE);\
  267. }
  268.  
  269. /*
  270.  * Trace a migrate operation.  The fields are
  271.  * 
  272.  * fromHostID:        Current client requesting migrate command
  273.  * toHostID:        HostID of machine to which to migrate
  274.  * streamID        Fs_FileID in the header of stream for this operation
  275.  * currentOffset    Offset of stream
  276.  */ 
  277. #define    SOSP_ADD_MIGRATE_TRACE(fromHostID, toHostID, streamID, currentOffset)\
  278. {\
  279.     unsigned int    sospBuffer[8];\
  280. \
  281.     sospBuffer[0] = SOSP_MIGRATE;\
  282.     sospBuffer[1] = fromHostID;\
  283.     sospBuffer[2] = toHostID;\
  284.     *((Fs_FileID *) &(sospBuffer[3])) = streamID;\
  285.     sospBuffer[7] = currentOffset;\
  286.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  287.     (7 * sizeof (int)),SOSP_MIGRATE);\
  288. }
  289.  
  290. /*
  291.  * Trace a truncate operation.  The fields are
  292.  * 
  293.  * streamID        Fs_FileID in the header of stream for this operation
  294.  * oldLength        Old length of the file
  295.  * newLength        New length of the file
  296.  * modify        Modify time of the file before truncation.
  297.  * create        Create time of the file before truncation.
  298.  */ 
  299. #define    SOSP_ADD_TRUNCATE_TRACE(streamID, oldLength, newLength, modify, create) \
  300. {\
  301.     unsigned int    sospBuffer[9];\
  302. \
  303.     sospBuffer[0] = SOSP_TRUNCATE;\
  304.     *((Fs_FileID *) &(sospBuffer[1])) = streamID;\
  305.     sospBuffer[5] = oldLength;\
  306.     sospBuffer[6] = newLength;\
  307.     sospBuffer[7] = modify;\
  308.     sospBuffer[8] = create;\
  309.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  310.         (8 * sizeof (int)),SOSP_TRUNCATE);\
  311. }
  312.  
  313. /*
  314.  * Trace a consistency change operation.  This trace is only a result
  315.  * of consistency updates due to a migrate call. The fields are
  316.  * 
  317.  * hostID:        ID of host causing the consistency change
  318.  * fileID        file ID of file causing the fuss
  319.  * operation        Is change due to opening or closing the reference?
  320.  *            This uses SOSP_OPEN, etc, defines.
  321.  * writeOp        Whether the open/etc operation is for writing (TRUE)
  322.  *            or reading (FALSE).
  323.  */ 
  324. #define    SOSP_ADD_CONSIST_CHANGE_TRACE(hostID, fileID, operation, writeOp) \
  325. {\
  326.     unsigned int    sospBuffer[8];\
  327. \
  328.     sospBuffer[0] = SOSP_CONSIST_CHANGE;\
  329.     sospBuffer[1] = hostID;\
  330.     *((Fs_FileID *) &(sospBuffer[2])) = fileID;\
  331.     sospBuffer[6] = operation;\
  332.     sospBuffer[7] = writeOp;\
  333.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  334.         (7 * sizeof (int)),SOSP_CONSIST_CHANGE);\
  335. }
  336.  
  337.  
  338. /*
  339.  * Trace a consistency action operation.  The fields are
  340.  * 
  341.  * causingHostID:    ID of host causing the consistency change
  342.  * affectedHostID:    ID of host affected by consistency change
  343.  * fileID        fileID of file causing the fuss
  344.  * action        Whether the action to take on the client is
  345.  *            FSCONSIST_WRITE_BACK_BLOCKS and/or
  346.  *             FSCONSIST_INVALIDATE_BLOCKS and/or
  347.  *            FSCONSIST_DELETE_FILE, etc.
  348.  *            These flags must be &'ed out since other flags may
  349.  *            also be set.
  350.  */ 
  351. #define    SOSP_ADD_CONSIST_ACTION_TRACE(causingHostID, affectedHostID, fileID, action) \
  352. {\
  353.     unsigned int    sospBuffer[8];\
  354. \
  355.     sospBuffer[0] = SOSP_CONSIST_ACTION;\
  356.     sospBuffer[1] = causingHostID;\
  357.     sospBuffer[2] = affectedHostID;\
  358.     *((Fs_FileID *) &(sospBuffer[3])) = fileID;\
  359.     sospBuffer[7] = action;\
  360.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  361.         (7 * sizeof (int)),SOSP_CONSIST_ACTION);\
  362. }
  363.  
  364. /*
  365.  * Trace a read operation on a write-shared file.  The fields are
  366.  * 
  367.  * hostID:        ID of host causing the consistency change
  368.  * fileID        ID of file causing the fuss
  369.  * streamID        Stream ID of file causing the fuss
  370.  * readIt        Whether the request is to read the file (TRUE) or
  371.  *            to write the file (FALSE)
  372.  * offset        Offset in the file at which to start operation
  373.  * numBytes        Number of bytes to read or write
  374.  * numNowReading    Number of clients with file open for reading
  375.  * numNowWriting    Number of clients with file open for writing
  376.  */ 
  377. #define    SOSP_ADD_READ_TRACE(hostID, fileID, streamID, readIt, offset, numBytes, numNowReading, numNowWriting)\
  378. {\
  379.     unsigned int    sospBuffer[15];\
  380. \
  381.     sospBuffer[0] = SOSP_READ;\
  382.     sospBuffer[1] = hostID;\
  383.     *((Fs_FileID *) &(sospBuffer[2])) = fileID;\
  384.     *((Fs_FileID *) &(sospBuffer[6])) = streamID;\
  385.     sospBuffer[10] = readIt;\
  386.     sospBuffer[11] = offset;\
  387.     sospBuffer[12] = numBytes;\
  388.     sospBuffer[13] = numNowReading;\
  389.     sospBuffer[14] = numNowWriting;\
  390.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  391.         (14 * sizeof (int)),SOSP_READ);\
  392. }
  393.  
  394. /*
  395.  * Trace a lookup operation.  The fields are
  396.  * 
  397.  * sospBuffer        Our buffer.
  398.  * hostID:        ID of host.
  399.  * streamID        Resulting stream ID of file.
  400.  * status        Status of the lookup.
  401.  * numIDs        Number of id's we got.
  402.  * op            The operation we're doing.
  403.  * clientID2        Another copy of client ID, for consistency checking.
  404.  * homeHostID        Migration client ID.
  405.  * op2            Another copy of the op we're doing.
  406.  * IDs            The ids we looked up (The caller stores these.)
  407.  */ 
  408. #define SOSP_LOOKUP_OFFSET 10*sizeof(int)
  409. #define    SOSP_ADD_LOOKUP(sospBuffer, hostID, streamID, status, numIDs, homeHostID, op)\
  410. {\
  411. \
  412.     sospBuffer[0] = SOSP_LOOKUP;\
  413.     sospBuffer[1] = hostID;\
  414.     sospBuffer[2] = homeHostID;\
  415.     *((Fs_FileID *) &(sospBuffer[3])) = streamID;\
  416.     sospBuffer[7] = status;\
  417.     sospBuffer[8] = numIDs;\
  418.     sospBuffer[9] = op;\
  419.     TraceLog_Insert(SOSP91TracePtr, (Address) sospBuffer,\
  420.         (SOSP_LOOKUP_OFFSET + numIDs*sizeof(Fs_FileID)),SOSP_LOOKUP);\
  421. }
  422.  
  423. /*
  424.  * Trace a prefix operation.  The fields are
  425.  * 
  426.  * sospBuffer        Our buffer.
  427.  * clientID        ID of host.
  428.  * rpcID        Rpc sequence number.
  429.  */ 
  430. #define    SOSP_ADD_PREFIX_TRACE(clientID, rpcID)\
  431. {\
  432.     unsigned int    sospBuffer[3];\
  433. \
  434.     sospBuffer[0] = SOSP_PREFIX;\
  435.     sospBuffer[1] = clientID;\
  436.     sospBuffer[2] = rpcID;\
  437.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  438.         (2 * sizeof(int)), SOSP_PREFIX);\
  439. }
  440.  
  441. #define SOSP_REMEMBERED_CLIENT  (Proc_GetCurrentProc()->rememberedClient)
  442. #define SOSP_REMEMBERED_MIG  (Proc_GetCurrentProc()->rememberedMig)
  443. #define SOSP_REMEMBERED_OP  (Proc_GetCurrentProc()->rememberedOp)
  444. #define SOSP_IN_NAME_LOOKUP  inNameLookup
  445. #define SOSP_IN_NAME_LOOKUP_FIELD  (Proc_GetCurrentProc()->SOSP_IN_NAME_LOOKUP)
  446.  
  447. /*
  448.  * Trace a lookup operation.  Note: this traces the name in
  449.  * Fsprefix_LookupOperation, while SOSP_LOOKUP traces the fileID's in
  450.  * FslclLookup.  This trace is used to cross-check the other.
  451.  *
  452.  * The fields are:
  453.  * sospBuffer        Our buffer.
  454.  * hostID:        ID of host.
  455.  * op            The operation we're doing.
  456.  * len            Length of the name.
  457.  * IDs            The ids we looked up (The caller stores these.)
  458.  */ 
  459. #define SOSP_LOOKUP_OP_OFFSET 4*sizeof(int)
  460. #define    SOSP_ADD_LOOKUP_OP(sospBuffer, hostID, op, len)\
  461. {\
  462. \
  463.     sospBuffer[0] = SOSP_LOOKUP_OP;\
  464.     sospBuffer[1] = hostID;\
  465.     sospBuffer[2] = op;\
  466.     sospBuffer[3] = len;\
  467.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  468.         SOSP_LOOKUP_OP_OFFSET -sizeof(int) + len, SOSP_LOOKUP_OP);\
  469. }
  470.  
  471. /*
  472.  * Trace a the deletion of a file descriptor. 
  473.  * 
  474.  * fileID        file ID of file being deleted.
  475.  * modify        Modify time for the file.
  476.  * create        Create time for the file.
  477.  * size            Size of the file.
  478.  */ 
  479. #define    SOSP_ADD_DELETE_DESC_TRACE(fileID, modify, create, size) \
  480. {\
  481.     unsigned int    sospBuffer[8];\
  482. \
  483.     sospBuffer[0] = SOSP_DELETE_DESC;\
  484.     *((Fs_FileID *) &(sospBuffer[1])) = fileID;\
  485.     sospBuffer[5] = modify;\
  486.     sospBuffer[6] = create;\
  487.     sospBuffer[7] = size;\
  488.     TraceLog_Insert(SOSP91TracePtr, (Address) (sospBuffer+1),\
  489.         (7 * sizeof (int)),SOSP_DELETE_DESC);\
  490. }
  491.  
  492.  
  493. #endif /* KERNEL */
  494. #endif /* _SOSP_RECORD */
  495. #endif /* SOSP91 */
  496.